home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Ham⁄GPS / SoftKiss.src.1.8 Folder / SoftKiss.src.1.8 / core / sfk_core_scc_asm.c < prev    next >
Text File  |  1992-04-17  |  3KB  |  129 lines

  1. /*
  2.  * SoftKiss scc access routines in c and assembler
  3.  * for use by code inside the device driver.
  4.  * by Aaron Wohl / N3LIW (aw0g+@andrew.cmu.edu) jul 1990
  5.  * 6393 Penn Ave #303
  6.  * Pittsburgh PA, 15206
  7.  * work: (412)-268-5032
  8.  * home: (412)-731-6159
  9.  */
  10.  
  11. /*
  12.  * define SCC_ASM_DEFS here for the assembler version of routines
  13.  * The assembler and c versions are compatable except for speed.
  14.  * At higher baudrates the c versions may not be able to keep up.
  15.  */
  16. #define SCC_ASM_DEFS
  17.  
  18. #include "sfk_core.h"
  19. #include "sfk_core_private.h"
  20.  
  21. #ifdef SCC_ASM_DEFS
  22. #pragma options(!require_protos)
  23. #endif
  24.  
  25. /*
  26.  * write a byte to a scc register
  27.  */
  28. #ifndef SCC_ASM_DEFS
  29. void sfk_write_scc(sfk_prt_pt p,uint8 rnum,uint8 val)
  30. {
  31.     *(p->ctl_wr)=rnum;
  32.     p->scc_reg_cache[rnum]=val;
  33.     p->sfk_IVAR(scc_ctl_writes)++;
  34.     sfk_SCC_COUNT_DELAY;
  35.     *(p->ctl_wr)=val;
  36. }
  37. #else
  38. void sfk_write_scc( /*sfk_prt_pt p,uint8 rnum,uint8 val */ )
  39. {
  40. asm {
  41.     move.l 4(sp),a1
  42.     move.l sfk_prt.ctl_wr(a1),a0     //a0=address of write reg
  43.     moveq.l #0,d0
  44.     move.b 8(sp),d0                    //d1 location to write
  45.     move.b d0,(a0)
  46.     addq.l #1,sfk_IVAR_ASM(scc_ctl_writes)(a1)
  47.     lea sfk_prt.scc_reg_cache(a1),a1 //get addr of write cache
  48.     move.b 0xa(sp),d1
  49.     move.b d1,(a1,d0)
  50.     move.b d1,(a0)
  51.     }
  52. }
  53. #endif
  54.  
  55. /*
  56.  * read a byte to a scc register
  57.  */
  58. #ifndef SCC_ASM_DEFS
  59. uint8 sfk_read_scc(sfk_prt_pt p,uint8 rnum)
  60. {
  61.     uint8 result;
  62.     if(rnum!=0)
  63.      *(p->ctl_wr)=rnum;
  64.     p->sfk_IVAR(scc_ctl_reads)++;
  65.     sfk_SCC_COUNT_DELAY;
  66.     result= *(p->ctl_rd);
  67.      return result;
  68. }
  69. #else
  70. uint8 sfk_read_scc( /* sfk_prt_pt p,uint8 rnum */)
  71. {
  72. asm {
  73.     move.l 4(sp),a1
  74.     move.l sfk_prt.ctl_wr(a1),a0     //a0=address of read reg
  75.     move.b 8(sp),(a0)                //d1 location to read
  76.     addq.l #1,sfk_IVAR_ASM(scc_ctl_reads)(a1)
  77.     move.l sfk_prt.ctl_rd(a1),a0     //a0=address of read reg
  78.     move.b (a0),d0
  79.     }
  80. }
  81. #endif
  82.  
  83. /*
  84.  * read a data byte
  85.  */
  86. #ifndef SCC_ASM_DEFS
  87. uint8 sfk_read_scc_data(sfk_prt_pt p)
  88. {
  89.     uint8 result;
  90.     result= *(p->data_rd);
  91.     p->sfk_IVAR(scc_data_reads)++;
  92.     sfk_SCC_COUNT_DELAY;
  93.      return result;
  94. }
  95. #else
  96. uint8 sfk_read_scc_data( /*sfk_prt_pt p */)
  97. {
  98. asm {
  99.     move.l 4(sp),a1
  100.     addq.l #1,sfk_IVAR_ASM(scc_data_reads)(a1)
  101.     move.l sfk_prt.data_rd(a1),a0     //a0=address of read reg
  102.     move.b (a0),d0
  103.     }
  104. }
  105. #endif
  106.  
  107. /*
  108.  * write a data to the scc
  109.  */
  110. #ifndef SCC_ASM_DEFS
  111. void sfk_write_scc_data(sfk_prt_pt p,uint8 val)
  112. {
  113.     *(p->data_wr)=val;
  114.     p->sfk_IVAR(scc_data_writes)++;
  115.     sfk_SCC_COUNT_DELAY;
  116. }
  117. #else
  118. void sfk_write_scc_data( /*sfk_prt_pt p,uint8 val*/ )
  119. {
  120. asm {
  121.     move.l 4(sp),a1
  122.     addq.l #1,sfk_IVAR_ASM(scc_data_writes)(a1)
  123.     move.l sfk_prt.data_wr(a1),a0     //a0=address of read reg
  124.     move.b 8(sp),(a0)
  125.     }
  126. }
  127. #endif
  128.  
  129.